home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / System / BoingBag1 / Contributions / InstallerNG / GUI-API / example / igui_CopyConfirm.c < prev    next >
C/C++ Source or Header  |  1999-10-28  |  4KB  |  153 lines

  1.  
  2. #include "includes.h"
  3. #include "installergui_data.h"
  4.  
  5. /********************************************************************
  6.  *
  7.  *  DESCRIPTION
  8.  *
  9.  */
  10.  
  11. /********************************************************************
  12.  *
  13.  *  STATIC
  14.  *
  15.  */
  16.  
  17. static void __asm __saveds copyconfirm_hookfun(register __a2 APTR , register __a1 LONG *);
  18.  
  19. static const struct Hook copyconfirm_hook = { { NULL, NULL }, (VOID *) copyconfirm_hookfun, NULL, NULL };
  20.  
  21. /********************************************************************
  22.  *
  23.  *  EXTERN
  24.  *
  25.  */
  26.  
  27. /********************************************************************
  28.  *
  29.  *  PUBLIC
  30.  *
  31.  */
  32.  
  33. /********************************************************************
  34.  *
  35.  *  CODE
  36.  *
  37.  */
  38.  
  39. long __asm igui_CopyConfirm(register __a0 APTR application,
  40.                             register __a1 struct FunctionEnvironment *localenv)
  41. {
  42.   #ifdef DEBUG
  43.   DEBUG_MAKRO
  44.   #endif
  45.  
  46.   {
  47.     struct Application *app = (struct Application *) application;
  48.  
  49.     long retval = 1,
  50.          event;
  51.  
  52.     ///// BPTR olddir;
  53.  
  54.     // create the object
  55.     APTR PO_path, HV_space,
  56.          obj = GroupObject,
  57.                  Child, TextObject,
  58.                     MUIA_Frame, MUIV_Frame_None,
  59.                     MUIA_Text_Contents, localenv->fe_Prompt,
  60.                     MUIA_Text_SetMin, TRUE,
  61.                     MUIA_Text_PreParse, "\33c",
  62.                  End,
  63.                  Child, app->app_DirlistList,
  64.                  Child, HV_space = HVSpace,
  65.                  Child, GroupObject,
  66.                     MUIA_Group_Horiz, TRUE,
  67.                     Child, Label(app->app_Texts[DESTDIR]),
  68.                     Child, PO_path = PopaslObject,
  69.                       MUIA_Popasl_Type, ASL_FileRequest,
  70.                       ASLFR_DrawersOnly, TRUE,
  71.                       MUIA_Popstring_String, String(localenv->fe_Dest, 80),
  72.                       MUIA_Popstring_Button, PopButton(MUII_PopFile),
  73.                     End,
  74.                     //Child, HSpace(10),
  75.                     //Child, BT_all = SimpleButton("All"),
  76.                     //Child, BT_none = SimpleButton("None"),
  77.                  End,
  78.                End;
  79.  
  80.     if (obj)
  81.     {
  82.       DoMethod(PO_path, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  83.                MUIV_Notify_Self, 3, MUIM_CallHook, ©confirm_hook, &(localenv->fe_Dest));
  84.  
  85.       // make the space invisible now!
  86.       set(HV_space, MUIA_ShowMe, FALSE);
  87.  
  88.       // set the help-text for this function
  89.       igui_SetHelp(app, (char *) localenv->fe_Help);
  90.  
  91.       // message object erzeugen und warten
  92.       if (guistuff_NewContent(app, obj))
  93.       {
  94.         // rename the "cancel" button to "skip this part"
  95.         igui_NameCancel(app, app->app_Texts[BUTTON_SKIP]);
  96.  
  97.         // wait, until the user "proceeds", "skips" or confirms the "quit" action
  98.         do
  99.         {
  100.           event = igui_QuietWaitApp(app);
  101.  
  102.           if      (event == GUIEVENT_PROCEED) { retval = 1; break; }
  103.           else if (event == GUIEVENT_ABORT)   { retval = 0; break; }
  104.         }
  105.         while (guistuff_HandleGUIEvent(app, event));
  106.  
  107.         // restore the "cancel" button
  108.         igui_NameCancel(app, app->app_Texts[BUTTON_PROCEED_INSTALL]);
  109.  
  110.         // before we quit, we must remove the dirlist from the group;
  111.         // otherwise mui would dispose the dirlist and this would lead a crash!
  112.         if(DoMethod(obj, MUIM_Group_InitChange))
  113.         {
  114.           // for better look, we show the space now to avoid window zipping
  115.           set(HV_space, MUIA_ShowMe, TRUE);
  116.  
  117.           DoMethod(obj, OM_REMMEMBER, app->app_DirlistList);
  118.           DoMethod(obj, MUIM_Group_ExitChange);
  119.         }
  120.       }
  121.       else { /* NO GUI OBjECT */ }
  122.     }
  123.     else { /* NO GUI OBjECT */ }
  124.  
  125.     igui_EmptyPanel(app);
  126.     return(retval);
  127.   }
  128. }
  129.  
  130. /******************************************************************************/
  131.  
  132. static void __asm __saveds copyconfirm_hookfun(register __a2 APTR obj, register __a1 LONG *data)
  133. {
  134.   // data[0] holds the address of localenv->fe_Dest
  135.  
  136.   // if the content of the "Destination directory:" string-gadget changes,
  137.   // we have to use the new content as the localenv->fe_Dest value, such that
  138.   // the insataller COPYFILES knows about the new destination!
  139.  
  140.   char *dest, *newdest;
  141.  
  142.   GetAttr(MUIA_String_Contents, (APTR) obj, (APTR) &dest);
  143.   if (newdest = sav_DupString2(dest))
  144.   {
  145.     *((APTR *) data[0]) = (APTR) newdest;
  146.   }
  147.   else
  148.   {
  149.     DisplayBeep(NULL);
  150.     SetAttrs(obj, MUIA_String_Contents, *((APTR *) data[0]), TAG_DONE);
  151.   }
  152. }
  153.